package com.yellow.feedbackservice.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    /**
     * 状态码
     */
    private int status;

    /**
     * 返回信息
     */
    private String message;

    /**
     * 返回数据
     */
    private T data;

    /**
     * 成功返回结果
     */
    public static <T> Result<T> success(T data) {
        return Result.<T>builder()
                .status(200)
                .message("Success")
                .data(data)
                .build();
    }

    /**
     * 失败返回结果
     */
    public static <T> Result<T> fail(String message) {
        return Result.<T>builder()
                .status(500)
                .message(message)
                .build();
    }
}